package com.yanqu.road.server.cmd.passRoad;

import com.yanqu.road.pb.pass.RoadProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.passRoad.PassRoadModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

import java.util.List;

@Cmd(code = Protocol.S_PASS_ROAD_EVENT_DEAL, desc = "新关卡事件处理")
public class PassRoadEventCmd extends AbstractCommand {


	private int passId;

	private int sectionId;

	private int eventId;

	//选择题选择的选项
	private int selectId;
	//派遣的门客列表
	private List<Integer> patronIdList;
	//赔钱的美女列表
	private List<Integer> beautyIdList;


	private String reward;

	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		RoadProto.RoadEventReqMsg reqMsg = RoadProto.RoadEventReqMsg.parseFrom(packet.getBytes());
		selectId = reqMsg.getSelectId();
		passId = reqMsg.getPassId();
		sectionId = reqMsg.getSectionId();
		eventId = reqMsg.getEventId();
		patronIdList = reqMsg.getPatronIdList();
		beautyIdList = reqMsg.getBeautyIdList();
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		reward = player.getModule(PassRoadModule.class).passEventReward(passId,sectionId,eventId,selectId,patronIdList,beautyIdList);
		ret = player.getModule(PassRoadModule.class).passEvent(passId,sectionId,eventId,selectId,patronIdList,beautyIdList);
	}

	@Override
	public void sendData(GamePlayer player) {
		RoadProto.RoadEventRespMsg.Builder respMsg = RoadProto.RoadEventRespMsg.newBuilder();
		respMsg.setRet(ret);
		respMsg.setReward(reward);
		player.sendPacket(Protocol.U_PASS_ROAD_EVENT_DEAL, respMsg);
	}
}
